package ui.converter;

import java.util.HashMap;
import java.util.Map;
import javafx.util.StringConverter;
import model.Attribute;

/**
 *
 * @author Merli András-Bertalan
 */
public class AttributeConverter extends StringConverter<Attribute> {

    private final Map<String, Attribute> mapAttributes = new HashMap<>();

    @Override
    public String toString(Attribute attribute) {
        mapAttributes.put(attribute.getName(), attribute);
        return attribute.getName();
    }

    @Override
    public Attribute fromString(String name) {
        return mapAttributes.get(name);
    }
}
